package com.lanvideo.service;

import com.lanvideo.dao.LearningNoteDao;
import com.lanvideo.entity.LearningNote;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 学习笔记服务
 */
@Service
public class LearningNoteService {

    @Autowired
    private LearningNoteDao learningNoteDao;

    /**
     * 保存笔记
     */
    public boolean saveNote(LearningNote note) {
        int result = learningNoteDao.saveNote(note);
        return result > 0;
    }

    /**
     * 更新笔记
     */
    public boolean updateNote(LearningNote note) {
        int result = learningNoteDao.updateNote(note);
        return result > 0;
    }

    /**
     * 删除笔记
     */
    public boolean deleteNote(Integer id) {
        int result = learningNoteDao.deleteNote(id);
        return result > 0;
    }

    /**
     * 根据ID获取笔记
     */
    public LearningNote getNoteById(Integer id) {
        return learningNoteDao.getNoteById(id);
    }

    /**
     * 获取用户的所有笔记
     */
    public List<LearningNote> getUserNotes(Integer userId) {
        return learningNoteDao.getUserNotes(userId);
    }

    /**
     * 获取视频的所有笔记
     */
    public List<LearningNote> getVideoNotes(Integer videoId) {
        return learningNoteDao.getVideoNotes(videoId);
    }

    /**
     * 获取用户对特定视频的笔记
     */
    public List<LearningNote> getUserVideoNotes(Integer userId, Integer videoId) {
        return learningNoteDao.getUserVideoNotes(userId, videoId);
    }

    /**
     * 搜索笔记
     */
    public List<LearningNote> searchNotes(Integer userId, String keyword) {
        return learningNoteDao.searchNotes(userId, keyword);
    }

    /**
     * 获取用户的笔记数量
     */
    public int getUserNoteCount(Integer userId) {
        return learningNoteDao.getUserNoteCount(userId);
    }

    /**
     * 获取视频的笔记数量
     */
    public int getVideoNoteCount(Integer videoId) {
        return learningNoteDao.getVideoNoteCount(videoId);
    }
}
